<?php

use yii\db\Query;
use console\db\channels\TransferTableMigration;

/**
 * 旧系统用户数据迁移至新用户表
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300000_000002_t_user extends TransferTableMigration {

    /**
     * 自定义查询
     * @inheritdoc
     */
    public function buildQuery() {
        $columns = [
            'uid',
            'username',
            'mobile',
            'email',
            'status',
            'regtime',
            'lastlogintime',
            'password',
            'salt',
        ];
        return $query = (new Query())->from('{{%' . $this->sourceTable . '}}')->select($columns);
    }

    /**
     * @see TransferTableMigration
     * @inheritdoc
     */
    public function getTransferOptions() {
        return [
            'table' => [
                'user' => 'member',
            ],
            'columns' => [
                'id' => 'uid',
                'username',
                'temp_mobile' => 'mobile',
                'email',
                'status',
                'created_at' => 'regtime',
                'updated_at' => 'lastlogintime',
                'password',
                'salt',
            ]
        ];
    }

}
